package com.esig.Model;

import com.esig.View.GameFrame;

import java.awt.*;

/**
 * 游戏父类
 */
public abstract class GameObject {
    //图片
    public Image img;
    //坐标
    public int dx1;
    public int dy1;
    //界面
    public GameFrame gameFrame;

    //构造方法
    public GameObject(String img, int dx1, int dy1, GameFrame gameFrame) {
        this.img = Toolkit.getDefaultToolkit().getImage(img);
        this.dx1 = dx1;
        this.dy1 = dy1;
        this.gameFrame = gameFrame;
    }

    public GameObject(String img, GameFrame gameFrame) {
        this.img = Toolkit.getDefaultToolkit().getImage(img);
        this.gameFrame = gameFrame;
    }

    //空的构造器，为了后期池初始化也是空
    protected GameObject() { }

    //绘制自身，如人物自身等
    public abstract void paintSelf(Graphics g);

    //绘制自身矩形 判断两个人物或物品是否相交
    public abstract Rectangle getRec();

    public Image getImg() {
        return img;
    }

    public int getDx1() {
        return dx1;
    }

    public int getDy1() {
        return dy1;
    }

    public GameFrame getGameFrame() {
        return gameFrame;
    }

    public void setImg(String img) {
        this.img = Toolkit.getDefaultToolkit().getImage(img);
    }

    public void setDx1(int dx1) {
        this.dx1 = dx1;
    }

    public void setDy1(int dy1) {
        this.dy1 = dy1;
    }

    public void setGameFrame(GameFrame gameFrame) {
        this.gameFrame = gameFrame;
    }
}
